Most voted "code-review" questions
DO NOT USE this tag for non-functional code, with bugs or problems. Just use this tag by providing already functional codes and a clear explanation of what the code does, so that the community can post improvements and optimizations (without changing its essential functionality).
Learn more…74 questions
Sort by count of
-
25
votes1
answer350
viewsOpenssl and ASP.NET Webapi
I am developing an internal application, but in a certain module I will need to travel a certain sensitive data. A priori I thought about using SSL, but due to limitations (non-technical) I won’t be…
javascript c# asp.net-web-api openssl code-reviewasked 8 years, 6 months ago Tobias Mesquita 22,900 -
19
votes2
answers594
viewsCollect Google Analytics data for Mysql tables
I have seen many examples of how to export data from Google Analytics to other formats as well as keep the exported data updated, but none so far served to export the data to Mysql given the…
-
11
votes1
answer152
viewsConvert PDF document pages to Jpgs
The following code is working within the desired, where it receives parameters in order to convert all pages of a PDF file into JPG files: ID (natural number) Absolute path (must exist and point to…
-
8
votes2
answers881
viewsHow to avoid code repetition between classes?
To report on my application I have created several classes, and each class is responsible for a report, however, there is a repetition of a lot of code by those classes that I would like to avoid,…
-
8
votes2
answers563
viewsPrompt Expression<Func<T, bool>> via parameter using object that is in a foreach
I have a model called Entity, this model has links (1 - N) with three other models. public class Entity { // Outras propriedades removidas para brevidade public virtual List<SpecificInfo>…
-
7
votes2
answers58
viewsDetermine the direction of the roll in an element
The code below aims to detect the direction of the roll in a specific element: var control = 0, lastScrollTop = 0, element = document.getElementById('idDoElemento'); element.onscroll = function() {…
-
7
votes1
answer182
viewsHow to improve this algorithm?
The goal of my algorithm is to make the user train division: he will have to hit 10 times in a row the quotient whole (that is, without decimal places) and the rest of the division. I made this…
-
6
votes1
answer180
viewsSelect database record for variable
The code below aims to select a database record and save it in a variable for later use of the data: #!/bin/bash dbName='basedados' dbUser='utilizador' dbPass='password' row=$(echo "select file_id,…
-
6
votes1
answer3485
viewsCPF generator in Javascript
I made a CPF generator in Javascript and, I wanted to know if my code is good or what I can improve on it? Function that will be called by the event onsubmit function gerarCpf() { var cpf =…
-
5
votes3
answers211
viewsHow could I improve the code?
Is there any way to improve this code? lista = [0,0,0,0,0] acuNota = 0 x = 0 arq = open("notas","w") while x <= 4: lista[x]= float(input("Insira uma nota por favor!")) acuNota = acuNota +…
-
5
votes2
answers928
viewsBest practices in the interaction between Activities
I’m developing an app just to validate the interaction between activities through intents. I created 5 ImageButton with an image for each one. Each button represents a movie and if the user clicks…
android android-studio android-layout code-reviewasked 9 years, 2 months ago Luiz Henrique Ugliano 651 -
5
votes1
answer790
viewsStrictly binary tree
A binary search tree is strictly binary if all tree nodes have 2 children or none. Implement a function that checks whether a binary search tree is strictly binary. // Estrutura de dados typedef…
-
5
votes1
answer127
viewsCode Review: Simple MVC
Hello world! I tried to make a very simple MVC in Javafx. My template is a class Pessoa who owns nome and idade (the field idade in case it is not used). Two text Fields represent two views. For…
-
5
votes1
answer64
viewsHow to know if the list contains so many elements that meet and do not meet a condition, using stream?
I have a list of columns, I need to know if this list contains both columns that are keys and columns that are not keys. I guarantee the existence of at least one column on the list My class of…
-
5
votes4
answers823
viewsTransform String Array into Object Array
I got the following Array string: ["TagFuncao:CN Evento:TODOS", "TagFuncao:DOC.AGRO.INDUS Evento:TODOS"] I need to transform this Array into an Object Array where TagFuncao and Evento is property of…
-
4
votes1
answer371
viewsAdd current page to browser bookmarks
The code below is working, but the technique is old and probably outdated compared to current versions of browsers: function addFavorite( a, b ) { title = document.title; url = document.location;…
-
4
votes1
answer191
viewsJavascript - How to improve this code?
As there is the Code Review Stack Exchange in Portuguese and Stack Overflow PT covers this topic I ask for help in a code that I am working on: suggestions and criticism regarding a chat script that…
-
4
votes3
answers239
viewsOrdering arrays with Bubble Sort
I’m solving a question of my course which I need to use a vector ordering algorithm based on the Bubble Sort algorithm. Making a previous summary, the logic consists of going through all the values…
-
4
votes0
answers48
viewsIdentify new, removed and modified objects from two ordered "collections" using extra O(1) memory in O(N) time
I have 2 "sets" of elements, neo and old, which has elements of the type T, all non-zero. Also, I know that these elements are identified by a key K and I can extract using this key using a…
-
3
votes2
answers91
viewsRefine article ranking based on views of all articles
The idea is to ascertain the reputation of a particular article based on the views of all existing articles. An article can have a reputation of 1 to 5 stars, the same being constantly changing…
-
3
votes1
answer3111
viewsHow to read and interpret a JSON file with PHP?
I am developing a PHP application, in which I am reading a JSON file (containing several electronic tax notes) and need to save some tags contained in this JSON file in variables. I started studying…
-
3
votes1
answer153
viewsAny more pythonic way to solve the problem below?
Create a function that returns the expression value: 2/3 + 3/5 + 4/7 + 5/9 + ... + n/m, to a user-defined value of n. Check that the user-defined n value is positive and, if not, request another…
-
3
votes0
answers104
viewsHow to proceed to implement a Preparedstatement on Android?
We are using the Sqldroid to work as a JDBC driver for Android. However, Sqldroid is an envelope for Android API calls, and this API does not deal well with nulls. So, for us to use…
-
2
votes1
answer82
viewsHow can I optimize my code?
I would like to optimize my code but I don’t know how to do it. It has to produce a result just like the one in the table above. Code: function calcular() { abiscissa =…
-
2
votes1
answer97
viewsDecrease responsibility of a class
I recently had the need to work with object-oriented sessions and created the following class: https://github.com/mateusdemboski/PHPsessionManager/blob/master/src/Session.php <?php /** * @author…
-
2
votes1
answer254
viewsConvert Mysql to Mysqli
3 Errors are presented: Notice: Undefined variable: save in C: xampp htdocs index.php on line 6 Warning: mysql_num_rows() expects Parameter 1 to be Resource, Boolean Given in C: xampp htdocs…
-
2
votes1
answer72
viewsLeave Component Following Cakephp’s Pattern
How can I improve this Cakephp 3.0 Component (inside the controller folder) Question discussed in: Post functional code in stackoverflow for refactoring? first: to use external libs (stored in…
-
2
votes1
answer118
viewsHelp in passing a jsFiddle code to an HTML file
I have a code in this jsFiddle which I changed, but now I’m having trouble passing it to an HTML file. My code: <!DOCTYPE html> <html lang="pt-BR"> <head> <meta…
-
2
votes2
answers1221
viewsCode revision of the CPF class in Java
You can review the code of my CPF class? A point of criticism is the use of regex which may be unnecessary. But in my view it makes the code shorter. Another point is the adoption of a class for…
-
2
votes0
answers57
viewsWhy is this C code vulnerable?
I’ve been doing some code analysis exercises and came across an interesting case. The exercise presents a C code with a function and asks what type of attack this code is vulnerable to. I couldn’t…
-
2
votes3
answers65
viewsHow to decrease the amount of if/Else for the same validation of different object properties?
I have some validations of mandatory fields in my application and today I do this way: verificarObrigatorios(): boolean{ if(!this.pessoa.nome) { this.toastr.showMessage("Nome Obrigatório") return…
-
2
votes0
answers61
viewsGithub - How to accept PR automatically after revisions?
I’m doing a project on Github and I’d like to structure something that after a certain amount of approvals in the revision, that happens to merge the pull request automatically. I know this is…
-
1
votes1
answer185
viewsCode review: field validations, how to abstract correctly?
In a Java Swing application I have four JTextFields: Weather minimum of handover of an order in minutes Weather maximum of handover of an order in minutes Weather minimum of withdrawal of an order…
-
1
votes0
answers117
viewsCakephp makes "action" and "template" more concise
I have some questions about how I can improve this "action" (method) in my "controller": Question discussed in: Post functional code in stackoverflow for refactoring? Man template has a navigation…
-
1
votes1
answer665
viewsHow to add counter to every if of my simple code
#include <stdio.h> #include <stdlib.h> int main() { float x,y; char k; do{ printf("Este Programa indica o quadrante no plano cartesiano\n"); printf("Entre com o valor de x:");…
-
1
votes0
answers63
viewsInternal server error, can anyone fix?
I set up a code to log into a website and download a spreadsheet, however, the connection has been closed, someone can help me? library(RCurl) curl = getCurlHandle() curlSetOpt(verbose = T,…
-
1
votes2
answers112
viewsUse same sorting algorithm with different attributes
Setting: I am developing a small application as a task of my course. As the intention of the work is precisely to show what we learned during the classes, I can not escape much of what I already…
-
1
votes2
answers576
viewsFunction or Method to Restart an Application on the C#console
Is there any available function or method to Restart the application on the C console#? static void decision() { Console.WriteLine("\n Press the home key to recalculate. . .",…
c# visual-studio code-review main console-applicationasked 5 years, 6 months ago Gabriel Castilho 11 -
1
votes1
answer111
viewsProgram to check number of words and a sentence of a text file
text file used: https://easyupload.io/j5agtq The method is part of a class called Arqtext Objective: The method does not use input and returns, in a tuple object, (1) the average number of words per…
-
1
votes1
answer128
viewsHow can I improve this code?
I am learning java and I found this challenge but when finishing I thought that the code was very polluted but I can not think of how to improve, I believe that using POO would be much easier but I…
-
1
votes1
answer87
viewsHow can I decrease the level of complexity of this function?
I’m learning development Web with HTML, CSS and Javascript and I came across the problem of generating a phone number with parentheses, dash and space. As I’m starting I developed a code that…
javascript function code-review number-formatasked 4 years, 3 months ago Rogério Rodrigues Sousa 19 -
1
votes1
answer125
viewsGreeting Functions "Good morning, Good afternoon and Good evening"
Today I came across a very interesting topic, which are the greetings "Good morning, Good afternoon and Good night" in Javascript (and among other languages..) Where in failed attempt to create a…
-
1
votes1
answer48
viewsHow to append a JSX component inside an item from . map()
I have this line structure: And my idea is that by clicking on each line, a JSX component is rendered according to the item that was clicked. I got it with the following code, but I feel it’s not…
-
0
votes1
answer43
viewsImprove css code
How can I improve the semantics of this code in css. Ex: I created two div’s with display:None attribute; and when passing the mouse on a parent div those div’s should qualify. .acaoBaixar,…
-
0
votes2
answers119
viewsHelps decrease the size of php mysql scripts
How could improve the script below, it would be possible to do something with the queries or yes thing, because it does everything I need, more became a bit messy and big, what could do? <?php…
-
0
votes1
answer127
viewsDoubt about Progress 4GL
I’m new to Progress development, and I’m having a hard time understanding what this piece of code does: define variable cRunFile as character no-undo initial "gpldnfbr.p". {us/gp/gpmnp02.i cRunFile…
code-reviewasked 6 years ago Mateus Costa Silva 1 -
0
votes1
answer80
viewsTable for Excel taking too long
Good , I have a query in the database , that returns me to depend on this query 5k lines to 30k lines , I’m generating already in excel through the code below , however when brings me about 5k of…
-
0
votes1
answer166
viewsImproving Login Logic - JDBC - Javaweb
I am developing the method of login of an application, but I’ve been realizing that the query I’m running to check if a user is registered in the system and if his password matches the database data…
-
0
votes0
answers59
viewsStream that reads byte per byte?
I created a simple byte-by-byte reading method in a stream, but it’s very slow and it’s taking minutes to process a ten-megabyte file, I don’t know why it’s so slow. It needs to be byte-by-byte and…
-
0
votes1
answer306
viewsString Encoding - Haskell
The following code encodes a sequence of equal characters, replacing the sequence with ! na, where n is the number of times the character a is repeated. Note that it only compresses sequences…